package com.atguifu.gulimall.coupon;

import org.springframework.util.StringUtils;

public class Solution {


    public static void main(String[] args) {

        boolean test = test("abc", "acb");
        System.out.println("test = " + test);
    }

    public static boolean test(String s, String goal) {
        boolean result = false;
        if (s.length()!=goal.length()){
            return result = false;
        }else if (s.equals(goal)&&s.length()==2){
            char[] chars = s.toCharArray();
            if(chars[0]==chars[1])
                return result = true;
        }else{
            char[] chars = s.toCharArray();
            for (int i = 0; i < chars.length; i++) {
                for (int j = 0; j < i; j++) {
                    char c = chars[i];
                    chars[i] = chars[j];
                    chars[j] = c;
                    String a = chars.toString();
                    if (a.equals(goal)) {
                        result = true;
                        return true;
                    }
                }
            }
        }
        return result;
    }
}
